<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::connection('mysql_log')->create('log_ad_postback', function (Blueprint $table) {
            $table->engine  = 'InnoDB';
            $table->comment('媒体回传日志');

            $table->increments('id');
            $table->integer('create_time')->comment('创建时间')->unsigned()->default(0);
            $table->integer('convert_type')->comment('转化上报类型 激活注册付费')->unsigned()->default(0);
            $table->integer('convert_time')->comment('转化时间')->unsigned()->default(0);
            $table->integer('plan_id')->comment('计划id')->unsigned()->default(0);
            $table->bigInteger('myad_group_id')->comment('整合广告组id')->unsigned()->default(0);
            $table->bigInteger('myad_ad_id')->comment('整合广告id')->unsigned()->default(0);
            $table->bigInteger('myad_creative_id')->comment('整合创意id')->unsigned()->default(0);
            $table->integer('media_id')->comment('媒体id')->unsigned()->default(0);
            $table->integer('media_docking_id')->comment('媒体对接id')->unsigned()->default(0);
            $table->integer('game_id')->comment('游戏id')->unsigned()->default(0);
            $table->integer('channel')->comment('渠道id')->unsigned()->default(0);
            $table->integer('firstup_ad_id')->comment('ad激活id')->unsigned()->default(0);
            $table->integer('firstup_id')->comment('激活id')->unsigned()->default(0);
            $table->integer('reg_time')->comment('账号注册时间')->unsigned()->default(0);
            $table->integer('mod_id')->comment('模块id')->unsigned()->default(0);
            $table->double('post_money', 16, 4)->comment('回传金额')->unsigned()->default(0);

            $table->tinyInteger('status')->comment('状态')->unsigned()->default(0);
            $table->integer('status_time')->comment('状态时间')->unsigned()->default(0);
            $table->integer('check_num')->comment('处理次数')->unsigned()->default(0);
            $table->integer('check_time')->comment('处理时间')->unsigned()->default(0);

            $table->index('convert_time');
            $table->index('convert_type');
            $table->index('plan_id');
            $table->index('media_id');
            $table->index('media_docking_id');
            $table->index('game_id');
            $table->index('channel');
            $table->index('firstup_ad_id');
            $table->index('firstup_id');
            $table->index('mod_id');
            $table->index('status');
            $table->index('myad_group_id');
            $table->index('myad_ad_id');
            $table->index('myad_creative_id');
            $table->index('reg_time');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::connection('mysql_log')->dropIfExists('log_ad_postback');
    }
};
